﻿@{
    Layout = null;
}

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="LoginPage">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>欢迎登录</title>
    <link href="@Href("~/css/style.css")" rel="stylesheet" type="text/css" />
    <script language="javascript" src="@Href("~/Scripts/jquery-1.10.2.js")" type="text/javascript"></script>
    <script src="@Href("~/Scripts/angularjs/angular.js")" type="text/javascript"></script>
    <script src="@Href("~/Scripts/cloud.js")" type="text/javascript"></script>

    <script language="javascript" type="text/javascript">
        if (window != window.top) {
            window.top.location.href = window.location.href;
        }
        console.log("...........,I can debug anything..");
        $(function () {
            $('.loginbox').css({ 'position': 'absolute', 'left': ($(window).width() - 692) / 2 });
            $(window).resize(function () {
                $('.loginbox').css({ 'position': 'absolute', 'left': ($(window).width() - 692) / 2 });
            });
            $("#name").focus();

            $('#pwd,#name').keydown(function (e) {
                if (e.keyCode == 13) {
                    $(".loginbtn").click();
                }
            });
        });

        angular.module('LoginPage', [])
            .controller('LoginBeanController', ['$http', function ($http) {
                var LoginBean = this;
                LoginBean.bean = { name: "admin", pwd: "admin", r: Math.random() };

                LoginBean.login = function () {
                    if (LoginBean.bean.name.length <= 0) {
                        alert("请输入用户名");
                        return false;
                    }
                    if (LoginBean.bean.pwd.length <= 0) {
                        alert("请输入密码");
                        return false;
                    }

                    $http.post('/Home/Login', LoginBean.bean)
                        .success(function (data, status, headers, config) {
                            if (!data.error) {
                                location.href = "/Home/Index";
                            } else {
                                LoginBean.bean = { name: "", pwd: "" };
                                alert(data.msg);
                            }
                        }).error(function (data, status, headers, config) {
                            alert(data.msg);
                        });
                };
            }]);
    </script>
</head>
<body ng-controller="LoginBeanController as LoginBean" style="background-color: #1c77ac;
    background-image: url(../../images/light.png); background-repeat: no-repeat; background-position: center top; overflow: hidden;">
    <div id="mainBody">
        <div id="cloud1" class="cloud">
        </div>
        <div id="cloud2" class="cloud">
        </div>
    </div>
    <div class="loginbody">
        <span class="systemlogo"></span>
        <div class="loginbox">
            <form id="login-fm" method="post" ng-submit="LoginBean.login()">
                <ul>
                    <li>
                        <input id="name" name="name" type="text" class="loginuser" ng-model=" LoginBean.bean.name " />
                    </li>
                    <li>
                        <input id="pwd" name="pwd" type="password" class="loginpwd" ng-model="LoginBean.bean.pwd" />
                    </li>
                    <li>
                        <input type="submit" class="loginbtn" value="登录" />
                        <label>
                            <a href="#">忘记密码？</a>
                        </label>
                    </li>
                </ul>
            </form>
        </div>
    </div>
    <div class="loginbm" style="display:none;">
        版权所有 2014 <a href="#">lilei.com</a>
    </div>
</body>
</html>
